-----------------------------------------------------------------------------
-- 羁绊红点
--
---------------
-- Author: wd
-----------------------------------------------------------------------------
require "Common/define"
require "Logic/Config"
require "Common/functions"

RedDotsFetterOneHeroHandler = {};
local this = RedDotsFetterOneHeroHandler;

function RedDotsFetterOneHeroHandler.init()
    CloseEvent(Config.EventType.Fresh_Star, this.update)
    ListenEvent(Config.EventType.Fresh_Star, this.update)

    CloseEvent(Config.EventType.Fresh_FetterDetial, this.update)
    ListenEvent(Config.EventType.Fresh_FetterDetial, this.update)


    CloseEvent(Config.EventType.Fresh_Mercenary, this.update)
    ListenEvent(Config.EventType.Fresh_Mercenary, this.update)

    return this;
end

--参数1：指定英雄Id，nil代表检查所有英雄
---英雄详情突破页签红点
local heroList = {};
function RedDotsFetterOneHeroHandler.getFlag(...)
    if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.LinkUnlock, false) then
        heroList = logicMgr.HeroManager.GetAllHero(true);
        for i = 1, #heroList do
            if heroList[i].partnerId ~= 0 then
                if logicMgr.FetterModel.GetOneHeroIsCanActive(heroList[i].partnerModelId) then
                    return Config.RedDotsFlagState.Needful
                end
            end
        end
    end
    return Config.RedDotsFlagState.None;
end

function RedDotsFetterOneHeroHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.OneHeroFetter);
end